<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>广州好 明天更好</title>
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no,minimal-ui"/>
<meta-equiv="Pragma"content="no-cache">
<meta-equiv="Cache-Control"content="no-cache">
<meta-equiv="Expires"content="0">
<link rel="stylesheet" href="http://g4cdn.airefp.com{$_C.hy_path}css/car/myanimate.css">
<link rel="stylesheet" href="http://g4cdn.airefp.com{$_C.hy_path}css/car/picao.css">
<link rel="stylesheet" href="http://g4cdn.airefp.com{$_C.hy_path}css/car/picao2.css">
<style>

	.cl-btn-blue
	{
		background-color:#eae000;
	}
	
	.cl-f-dblue
	{
		color:#eae000;
	}
	
</style>
</head>
<body>
<!--<div style="margin:0 auto; display:none;"><img src="images/fenx.jpg" /></div>-->
<img id="loading" src="http://g4cdn.airefp.com{$_C.hy_path}images/car/loading_1.gif">
<!--<b class="tips"></b>-->
<div id="wrap">
    <div id="imgs">
    	       
		<div class="img">
            <img class="animated" src='http://g4cdn.airefp.com{$_C.hy_path}images/car/bg.png'/>
            <img class="animated bounceInDown" src='http://g4cdn.airefp.com{$_C.hy_path}images/car/logo.png'/>
            <img class="animated fadeInDown delay15" src='http://g4cdn.airefp.com{$_C.hy_path}images/car/son.png'/>
            <img class="animated fadeInDown delay25" src='http://g4cdn.airefp.com{$_C.hy_path}images/car/footer2.png'/>
            <img class="animated fadeInDown delay35 " onclick="ajax_prize()"  src='http://g4cdn.airefp.com{$_C.hy_path}images/car/prize_btn.jpg'/>
        </div>
    </div>
	<div id="navs" hidden>
    <a href="javascript:;" class="active"></a>
    <a href="javascript:;"></a>
    <a href="javascript:;"></a>
    <a href="javascript:;"></a>
    <a href="javascript:;"></a>
    <a href="javascript:;"></a>
    </div>
    
</div>

<div class="yhq-alert-wrapper alert-wrapper hide">
		<div class="yhq-alert alert moveFromTop">
			<i class="icon-close"></i>
			<div class="yhq-list col pada-20 marb-35">
				<!-- <div id="photo-img" class="photo-img">
					<img src="http://g4cdn.airefp.com{$_C.hy_path}images/card/photo-img.png" alt="">
				</div> -->
				<div class="photo-info">
					
					<p style="text-align:center;margin-top:30px"  id="yhq-info" data-id="0" class="yhq-info text-overflow font-16 marb-8" ></p>
					<p style="text-align:center" id="yhq-name" class="yhq-name text-overflow font-12 marb-8"></p>
				</div>
			</div>
			<p class="btn-con"><a   onclick="try_card()" href="javascript:;" class="btn font-14 cl-btn-blue marb-5">立即领取</a></p>
			<p class="cl-f-dblue font-12">（卡券领取后将添加到微信卡包）</p>
		</div>
	</div>
	
<script type="text/javascript" src="http://g4cdn.airefp.com{$_C.hy_path}/js/car/jquery.min.js"></script>
<script type="text/javascript" src="http://g4cdn.airefp.com{$_C.hy_path}/js/car/pageSwitch.js"></script>
<script src="http://g4cdn.airefp.com{$_C.hy_path}/js/car/indexs.js"></script>
<script src="http://g4cdn.airefp.com{$_C.hy_path}/js/car/toast.js"></script>
{include file="../Common/g4-share-picao.html"}
<script>


	
	$(function(){
		
		$('.get').click(function(){
			
			var yhqAlert = $('.yhq-alert-wrapper');
			 yhqAlert.removeClass('hide');
			 /*
			yhqAlert.find('#photo-img').find('img').attr('src',yhqImg);
			yhqAlert.find('#yhq-name').text(yhqName);
			yhqAlert.find('#yhq-info').text(yhqInfo);
			yhqAlert.find('#yhq-info').attr("data-id",cardId);
			
			yhqAlert.find('#yhq-last-data').text(yhqDate); */
		});
		$('.alert-wrapper .icon-close').click(function(){
			$(this).parent().parent().addClass('hide');
			
		});
	
	})
	
	
	
	var prize_user_id = ''; 
	
	var is_get = false;
	
	var is_prize = false;
	
	var is_try = false;
	
	 
		
		  
		
	
	
    function ajax_prize()
	  {
		
    	
		  var url = "index.php?g=mobile&m=car&a=ajaxPrize";
			
			$.post(url,{ card_type:2 },function(data){
				 
		         if(data.error==1){
		        	 
		        	 
		        	 if(data.data.is_card>0)
	        		 {
		        		 warn("你已经领过该奖了~");
		        		 return;
	        		 }
		        	 
		        	 var yhqAlert = $('.yhq-alert-wrapper');
					 yhqAlert.removeClass('hide');
					 yhqAlert.find('#yhq-info').text(data.data.prize_name);
					 yhqAlert.find('#yhq-name').text(data.data.mark);
		        	 prize_user_id = data.data.user_id;
		        
		        	
		         }else{
		        	 warn("很抱歉你没有中奖~");
		        	 
		        	 prize_user_id = 0;
		        	
		         }
				 
			},"json");
	  
  	
	  }
    	
    
    
	  function try_card()
	  {
		
		  if(is_prize == true)
		  {
		  	warn("你已领取过奖品了");
		  	return;
		  }
		  
		  if(is_get == true)
		  {
		  	warn("奖品领取中");
		  	return;
		  }
		  
		  is_get = true;
		  
		  var url = "index.php?g=mobile&m=car&a=ajaxCard";

		  var data = {
				  id:prize_user_id
		  };
		 
			$.post(url,data,function(cardlist){
				is_get = false;
				
				 wx.addCard({
		              cardList: cardlist,
		              success: function (res) {
		            	  
		            	  is_get = true;
		            	  
		            	  is_prize = true;
		            	  
		            	  get_card(prize_user_id);  
		              }
		            });
				 
				 
				 
			},"json");
    	  
      	
	  }
	  
	  
	  //领取卡券后异步回调
	  function get_card(id)
	  {
			  
		  var url = "index.php?g=mobile&m=car&a=getCard";
			
		  var data = {
				  id:id
		  }
			$.post(url,data,function(res){
				//showMsg("领取成功。");
				
				//window.location.href="index.php?g=mobile&m=car&a=shake";
				//document.getElementById('mcover').style.display='block';
				
			},"text");
    	  
      
	  }
	  
</script>
</body>
</html>
